      

package reittiopas;

import java.util.Vector;

/**
*
* @author Jaakko, Petteri
*/

public class SubRoute {

    private Vector locations;
    private int transportation; //from ReittiopasDefinitions.Transportation
    private String vehicleNumber;
    private String totalDistance;  //in meters
    private String totalTime; //in minutes
    private String arrivalTime; //format: HHMM
    private String departureTime;
    
    
	public SubRoute(Vector locations, int transportation, String totalDistance, String arrivalTime, String departureTime) {
        this.locations = locations;
        this.transportation = transportation;
        this.totalDistance = totalDistance;
        this.arrivalTime = arrivalTime;
        this.departureTime = departureTime;
    }
	
	

    public Location getDestinationLocation() {
		return (Location)this.locations.lastElement();
	}




	public Vector getIntermediateLocations() {
		Vector temp = new Vector();
		if (this.locations.size() >= 3)
			for (int i = 1; i < this.locations.size()-1; i++)  //get all other elements but the first and last
				temp.addElement(this.locations.elementAt(i));
		return temp;
	}


	public void addLocation(Location location) {
		this.locations.addElement(location);
	}
    
    
    public String getTotalTime() {
		return totalTime;
	}


	public String getTotalDistance() {
		return totalDistance;
	}


	public void setTotalDistance(String totalDistance) {
		this.totalDistance = totalDistance;
	}


	public void setTotalTime(String totalTime) {
		this.totalTime = totalTime;
	}


	public SubRoute() {
    	this.locations = new Vector();
    }


    public String getArrivalTime() {
		return arrivalTime;
	}


	public void setArrivalTime(String arrivalTime) {
		this.arrivalTime = arrivalTime;
	}


	public String getDepartureTime() {
		return departureTime;
	}


	public void setDepartureTime(String departureTime) {
		this.departureTime = departureTime;
	}

 

    public Location getStartLocation() {
    	return (Location)this.locations.firstElement();
    }

    public int getTransportation() {
        return transportation;
    }

    public void setTransportation(int transportation) {
        this.transportation = transportation;
    }
    
  
 
    
    public String getVehicleNumber() {
		return vehicleNumber;
	}


	public void setVehicleNumber(String vehicleNumber) {
		this.vehicleNumber = vehicleNumber;
	}


	public String getFullDescription() {
		String fullString = "" + this.getStartLocation().getDepartureTime() + " ";
    	if(this.getTransportation() == ReittiopasDefinitions.Transportation.BUS){
    		fullString += "Bus";
    	}
    	else if(this.getTransportation() == ReittiopasDefinitions.Transportation.WALK){
    		fullString += "Walk";
    	}
    	else if(this.getTransportation() == ReittiopasDefinitions.Transportation.FERRY){
    		fullString += "Ferry";
    	}
    	else if(this.getTransportation() == ReittiopasDefinitions.Transportation.SUBWAY){
    		fullString += "Subway";
    	}
    	else if(this.getTransportation() == ReittiopasDefinitions.Transportation.TRAIN){
    		fullString += "Train";
    	}
    	else if(this.getTransportation() == ReittiopasDefinitions.Transportation.TRAM){
    		fullString += "Tram";
    	}
    	
    	if(this.getTransportation() != ReittiopasDefinitions.Transportation.WALK) {
    		fullString += " " + this.getVehicleNumber();
    	}
    	
    	//fullString += "(Duration: " + this.getTotalTime() + ", Distance: " + this.getTotalDistance() + ") \n"; 
    	fullString += " " + this.getStartLocation().getFullAddress()+ "\n";
    	

//		for(int i=0; i<this.getIntermediateLocations().size(); i++) {
//			Location location = (Location)this.getIntermediateLocations().elementAt(i);
//			fullString += "--->" + location.getArrivalTime() + " " + location.getFullAddress() + "\n";
//    		}
//		fullString +="->" + this.getDestinationLocation().getArrivalTime() + " " + this.getDestinationLocation().getFullAddress() + "\n";
    	return fullString;
    }
    
}
